//
//  JQFYMyshowListModel.m
//  JQFY
//
//  Created by 代辉 on 2017/10/20.
//  Copyright © 2017年 yannis. All rights reserved.
//

#import "JQFYMyshowListModel.h"

@implementation JQFYMyshowListModel {
    NSArray *_myshowList;
}

- (void)getMyshowList:(void (^)(NSArray *))sucess file:(void (^)(NSError *))file
{
    [[AFHTTPSessionManager manager] POST:@"http://app.uninhibited.cn/api/buy/order/ticket/list" parameters:@{@"token":[JQFYUserData userDataInSandbox].token} progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        _myshowList = [NSArray yy_modelArrayWithClass:[self class] json:responseObject[@"msg"]];
        sucess(_myshowList);
        
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        if (error) {
            file(error);
        }
    }];
}

- (void)verificationQRcode:(void (^)(NSString *, NSInteger))sucess file:(void (^)(void))file orderID:(NSString *)orderID
{
    NSDictionary *dict = @{
                           @"token":[JQFYUserData userDataInSandbox].token,
                           @"out_trade_no":orderID
                           };
    [[AFHTTPSessionManager manager] POST:@"http://app.uninhibited.cn/api/buy/order/ticket/code" parameters:dict progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        if ([responseObject[@"status"] isEqualToString:@"error"]) {
            return ;
        }
        if (responseObject[@"msg"][@"code_path"]) {
            sucess(responseObject[@"msg"][@"code_path"],[responseObject[@"msg"][@"code_status"] integerValue]);
        }
        
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        if (error) {
            file();
        }
    }];
}
@end
